<?php
declare (strict_types = 1);

namespace app\shop\controller;

use app\Normal;
use app\Request;
use think\annotation\Route;
use think\annotation\route\Group;
use app\common\service\DecorateService\DecorateService;
use think\annotation\route\Middleware;

/**
 * 装修模板
 * @Group("Decorate")
 * @Middleware({shopMiddileware::class})
 */
class Decorate extends \app\BaseShopController
{
    /**
     * 装修主页
     * @Route("templateInfo/:type",method="GET")
     * @return void
     */
    public function templateInfo(Request $request){
        $result = callApi(DecorateService::class, 'templateInfo',$this->_all_data);
        return apiResponse($result);
    }

    /**
     * 设置/更换微页面
     * @Route("setTemplate",method="POST")
     * @param Request $request
     * @return void
     */
    public function setTemplate(Request $request){
        $result = callApi(DecorateService::class, 'setTemplate',$this->_all_data);
        return apiResponse($result);
    }

    /**
     * 图片列表
     * @Route("pictureLists",method="GET")
     * @return void
     */
    public function pictureLists(Request $request){
        $result = callApi(DecorateService::class, 'pictureLists',$this->_all_data);
        return apiResponse($result);
    }

    /**
     * 新增图片
     * @Route("addPicture",method="POST")
     * @return \think\Response|\think\response\Json
     */
    public function addPicture(Request $request){
        $result = callApi(DecorateService::class, 'addPicture',$this->_all_data);
        return apiResponse($result);
    }

    /**
     * 编辑图片
     * @Route("editPicture",method="PUT")
     * @return \think\Response|\think\response\Json
     */
    public function editPicture(Request $request){
        $result = callApi(DecorateService::class, 'editPicture',$this->_all_data);
        if($result['code'] == Normal::SUC){
            $this->log(['content'=>'编辑ID为【'.$this->_all_data['id'].'】的活动长图','request_param'=> json_encode($this->_all_data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
        }
        return apiResponse($result);
    }

    /**
     * 删除活动图片
     * @Route("delPicture",method="POST")
     * @return \think\Response|\think\response\Json
     */
    public function delPicture(Request $request){
        $result = callApi(DecorateService::class, 'delPicture',$this->_all_data);
        if($result['code'] == Normal::SUC){
            $this->log(['content'=>'删除ID为【'.$this->_all_data['id'].'】的活动长图','request_param'=> json_encode($this->_all_data,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)]);
        }
        return apiResponse($result);
    }
}